version of unit 2.76
English version(Czech text follows)

If you hate more text run the program DEMO.EXO with parameter LYNNE.PCX
(or other picture) first.

1. Compilation of unit

      The source code was written in environment Turbo Pascal r 7.0
(real, protected and windows) and should be translated in new releases.
It was successfully tried to using this unit under Delphi r 1.0. The
file MODIF.INC must be created for compilation. This file may be empty.
If a program will run in graphics mode, the following line must be
included in file MODIF.INC:
{$define graph}

2. Data structures

In the base lie a picture object with a following items:
     picture=object(AbstractPicture)
      filename:pathstr;
      x,y:integer;
      planes:byte;
      data:^lines;

      Function Valid:Boolean; virtual;
      procedure View; virtual;
      procedure Create(SizeX,SizeY:Word;pln:Byte);
      procedure Erase;
      Constructor Init;
      Destructor Done;
      end;

where:x,y         mean size of picture
    planes        number of bit planes (lze pouzit pouze 1,2,4,8) If
                  picture is loaded this value is not recomended to
                  change
    data          pointer to data stored in memory
    filename    name of disk file, where is picture stored

And following object describes vector picture data:
     VectorPicture=object(AbstractPicture)
      xscale,yscale:integer;
      lines:Word;
      v:^AVectorObject;

      Procedure View; virtual;
      Procedure Erase;
      constructor Init;
      destructor Done;
      end;

where       xscale,yscale     sizes of vector picture
            lines             number of vector objects in item v
            v           pointer to item of pointers to single vector
                        objects

Here is definition of vector objects:
     VectorObject=record
      points:word;
        color:Byte;
      data:array[0..0] of point;
      end;

where points      number of points (vertexes) obsaench v objektu
      color       the color of object
      data        pole jednotlivch bod patcch objektu


Structure where is stored histogram data:
     PHistogram=^THistogram;
     THistogram=Array[0..255]of Longint;

Agreement:Axis Y is position of row. (Rows are stored separately)
      Axis X is position of column (pixel in row).

3. Basic methods of object picture

Function picture.Valid:Boolean; virtual;
      Returning value is True, if picture contains valid data. Else
False is returned.

procedure picture.View; virtual;
      Object is showed on the screen. (see also procedure View). Switch
{$define graph} must be defined.

procedure picture.Create(SizeX,SizeY:Word;pln:Byte);
      A new free picture is created, which have needed size and depth
of a color.

procedure picture.Erase;
      All object data are erased. Only one exception is the disk file
name. This method can be called anywhere in program.

Constructor picture.Init;
      Initialization of all data object. This method must be called
before first using of this object.

Destructor picture.Done;
      At first is called method picture.Erase and then all information
are destructed.

4. Procedures for processing pictures

4.1. Mask filtration
  Procedure Mask(var Obr1,Obr2:Picture;n:Byte);
        The mask filtration is done. Size of a mask is n. Input picture
is stored in obr1 and output picture is stored in obr 2. Algorithm of
decomposed mask is used, and its speed doesn't depend on sizes of mask.

4.2. Median filtration
  Procedure Median(var Obr1,Obr2:Picture;n:Byte);
        This procedure accomplish median filtration from picture Obr1
to pictur Obr2 with size n. After calling procedure is one of 2
algorithms selected according to size of element. For n<8 is selected
fast algorithm with time consumption n^3 and for greater n another
algorithm is used with time consumption k*n^2. The time for n>20 may
be too long.

4.3. Copy of image
  Procedure MovePicture(var srP,destP:picture);
      This procedure copy contents of the source picture to the
destination picture. If destination picture was not clear, then its
contents was overwritten. No changes are performed on the source
picture.

4.4. Gaussian mask
Procedure Gauss(var Obr1,Obr2:Picture;n:Byte);
        This procedure accomplish filtration with gaussian from picture
Obr1 to pictur Obr2 with size n.

4.5. Crop of image:
Procedure Crop(var Obr1,Obr2:Picture;x0,y0,x1,y1:word);
        Cropped obr1 with axises x0,y0,x1,y1.is stored to obr2.
If parameter y1=0, then axises y0 and y1 are selected automatically
If parameter x1=0, then axises x0 and x1 are selected automatically
      Automatical selection cuts border of picture with the same color.

4.6. Edge detection
Procedure Canny(var im_in,im_out:picture;GausN:integer;scale:real);
      This procedure accomplish detection of edges from picture im_in.
Result of this operation is stored in picture im_out. Parameter GausN
tells size of Gausssian mask. It means number of iteration steps with
using elemental mask 3x3 - it is scale of image. Parameter scale avoid
multiplying result with const. This may be useful if results of canny
detection is too slow or too high.
      Null or negative value of parameter GausN modify activity of edge
detection following way:
Algorithm now perform edge back-tracking throw scales from starting
scale in parameter GausN downto 1. (gausN,abs(scale)) -
>...->(1,abs(scale)). If GausN=0 then starting value of the scale is
40.

4.7. Operations with one picture
  Procedure Operation1(var obr1:picture;
      Operation:func1; ukParameters:Pointer);

        This procedure perform transformation of brightness in one
picture, passed as parameter, and result is stored to same picture.
Parameter Operation contains selected function. User defined data,
pointer to it is stored in parameter Param are passed to this
procedure, when this is called.
These following functions are predefined:

 Procedure Invert(P1:Pointer;MaxX:Word;Dummy:pointer);            {R=-R}
 Procedure ReTabB(P1:Pointer;MaxX:Word;TabPtr:pointer);           {R:=Tab[R]}

      User may define any new function and pass it as parameter. Only
one conditions must be realized: procedure must be far type and its
header must be same with the following definition:
     func1 = Procedure(P1:Pointer;MaxX:Word;ukParameters:Pointer);

4.8. Operations with two pictures
  Procedure Operation2(var obr1,obr2:picture;
      Operation:func2; Param:Pointer);

      This procedure perform transformation of brightness from two
pictures and result is stored to obr2. Parameter Operation contains
selected function. User defined data, pointer to it is stored in
parameter Param are passed to this procedure, when this is called.
These following functions are predefined:

Procedure SubbS(P1,P2:Pointer;MaxX:Word;Dummy:pointer);           {R1:=R2-R1}
Procedure Add(P1,P2:Pointer;MaxX:Word;Dummy:pointer);             {R1:=R2+R1}

4.9. Computation of histogram
  Procedure Histogram(var p:picture;var H:Phistogram);


5. Operations with binary pictures

Definition of structure element:

      For morphology operation it is required as parameter form of
structure element. This element will be used for convolution. Following
types of structure elements are predefined:
const ElLup=  4;   ElUp   =8;   ElRup  =16;
      ElLeft= 2;   ElCentr=1;   ElRight=32;
      ElLdown=256; ElDown =128; ElRdown=64;

      Using combination of this single elements you may make up any
structure element till size 3x3. There are also predefined two arranged
elements:
 El8=ElLup+ElUp+ElRup+ElLeft+ElCentr+ElRight+ElLdown+ElDown+ElRdown;
 El4=ElUp+ElLeft+ElCentr+ElRight+ElDown;

5.1. Tresholding
  Procedure Thr(var Obr,ph:picture;h:integer);
      It is executed tresholding of image Obr with threshold value h.
Final binary image is stored into structure ph. Threshold value 0 is
reserved for automatic choice of the value h {!!it will be implemented
in future releases!!}.

5.2. Dilatation
  Procedure Dilatation(var Obr,ObrD:Picture;typ:Word);
      Input picture is dilatated with using structure element typ.
Final image is stored to structure ObrD (For the present this procedure
works only with binary images!). Variable typ contains fashion of the
structure element.

5.3. Erosion
  Procedure Erosion(var Obr,ObrD:Picture;typ:Word);         Input picture
is erosed with using structure element typ. Final image is stored to
structure ObrD (For the present this procedure works only with binary
images!). Variable typ contains fashion of the structure element.

5.4. Binary operations with two images
  Procedure BinarOperation2(var Obr1,Obr2:Picture;
Operation:BinarFunc2);
        This procedure perform passed binary function from two binary
images. Parameter Operation contains desired function. For the present
there are defined following functions:
 Procedure XorR(maxX:Word;R1,R2:Pointer);       {R1:=R1 xor R2}
 Procedure OrR(maxX:Word;R1,R2:Pointer);        {R1:=R1 or R2}
 Procedure AndR(maxX:Word;R1,R2:Pointer);       {R1:=R1 and R2}
      User can add any new function. This function may be then passed
as parameter. Only one condition is then procedure must be far type and
its header must be same with this definition:
     Binarfunc2 = Procedure(maxX:word;p1,p2:pointer);

6. Input/Output Operations

6.1. Loading the image
  Procedure LoadPicture(var p:AbstractPicture;const s:PathStr);
      Image with engaged name s is loaded from disk. Type of the image
is recognized from type of passed variable p. The file name is
contained in variable s. If empty string is passed, it is used implicit
name of image in variable p.filename.. This name can be changed using
procedure AssignPicture.
      It is supported following formats of bitmap images: (BMP, GIF,
PCX, RAS, OKO, FTG, TXT). For vector images there are available two
formats: .TXT (text) a .HPG (text for plotter).

6.2. Saving image
  Function SavePicture(var p:picture;const s:PathStr):Boolean;
      This function store image to disk. Type of the image data is
founded from type of image variable passed in parameter p. The file
name is included in variable s. If the string is empty, then implicit
name of image is used. Implicit name is located in variable p.filename.
You may change implicit name using procedure AssignPicture.
      Following bitmap image formats are supported:(BMP, PCX, RAS, OKO,
FTG, TXT). For vector image are supported these two formats: .TXT
(text) and .HPG (text for plotter).

6.3. New image format FTG
      FTG is defined in additional unit FTGR.PAS. It contains new
method of image compression, that has best performance of compression
ratio.
Comparison of lengths:        

data type:    Fig A      Fig B       Fig C
      OKO   262656      442112      106940
      ZIP   227173      220369       10224
      ARJ   228451      220547       10380
      AIN   228496      221045       10559
      PCX   288650      377897       38624

      FTG   199697      177539        8922      - new format
            196440                              -   + LZW

Figure A is gray scaled 256 levels of brightness scanned using the
camera - artificial scene.
Figure B is gray scaled 256 levels of brightness scanned using the
camera -sight into the room.
Figure C is binary image - technical drawing (graphs).

7. Other procedures for manipulation with images

7.1. Displaying
  Procedure view(var p:abstractPicture);
      Image stored in variable p is displayed. For using this function
must be feature graphics enabled. In file MODIF.INC must be included
{$define graph}.

7.2. Reading value of the pixel
  Function pixel(var p:picture;x,y:integer):Word;
      This function returns value stored in the image pixel on position
[x,y]. If needed coordinates of the actual point lies outside figure,
then nearest point in picture is selected. Algorithm uses this equation
for the selection: [max(0,min(SizeX,X)), max(0,min(SizeY,Y))].

7.3. Set pixel value
  Procedure SetPixel(var p:picture; x,y:integer; n:Word);
      This procedure modify value of the pixel on position [x,y]. If
needed coordinates of the actual point lies outside figure, then
nearest point in picture is selected. Algorithm uses this equation for
the selection: [max(0,min(SizeX,X)), max(0,min(SizeY,Y))].

7.4. Format of a row
  Procedure FormR(var p:picture; i:integer; Data:Pointer);
      All row is converted into unified format words. Pointer Data
points onto array of words. Memory with correct size must be allocated
before calling this procedure. If needed number of row exceeds size of
image then compensatory line is selected according to equation:
max(0,min(SizeY,Y)).

7.5. Set of row
  Procedure RfrmB(var p:picture;i: integer; NewData:Pointer);
      All rows elements are changed. New values are getted from array
of words. Pointer NewData points onto this array. This perform inverse
operation to previous FormR. If needed number of row exceeds size of
image then compensatory line is selected according to equation:
max(0,min(SizeY,Y)).

8. Ready programs

      Some complete programs are added to unit pictures. These
demonstrate its abilities in processing images. You may use some of
these routines independently.
Executable files are stored into 3 directories according to used
environment:
  DOS       works only in real mode
  DPMI      works only in DPMI mode - you may work with great pictures
  WIN       works in Windows


8.1. Convert

Parametters:input_image output_image [OutputPlanes] [/Gray] [/NoScale]
            /?          print text help
            /Gray       destroy palette and transfer colors into gray
                        scale
            /NoScale    In conversions of bit planes data will be not
                        recounted or scaled, but they'll be cutted.
            OutputPlanes      Number of bit planes in the output image.

      This program make conversion input image into output image. In
this conversion is change of number bitplanes or removing palette
allowed. Number of bitplanes may be one only of these numbers [1, 2,
4, 8, 16, 24]. If the noscale switch is on, data isn't transformed (or
multiplied) any way. If some value overcome maximal allowed number,
this max number depend on number of bit planes, then the pixel is set
to this maximal value (cutting).

8.2. View

Parametters:name_of_image      show image on the screen
            /?          print text help
      This programm is designated for viewing images on the monitor
screen. It support modes with 256 colors. It is abble to display all
formats which procedure LoadPicture can load:
      BMP         1,4,8,24 bit planes + palette
      FTG         1,2,4,8,16,24,32 planes (+selectable palette)
      GIF         1,2,4,8 planes + paltte
      OKO         1,8 bit planes (only gray scalled)
      PCX         1*1,1*2,1*4,8*1 + palette
      RAS         types 0(1b),1(8b),2(8b),3(4b),4(4b)

      In viewing user can interactively change resolution of screen 
using function keys from F1 till F6. If user press key G, then palette
is temporary converted to gray/restored to original colors.



Czech version (English text is situated in the beginning)

9. Peklad jednotky

      Zdrojov text je napsn v prosted Turbo Pascalu v 7.0 (real,
protected i windows) a ml by bt peloziteln i pro vy verze. Byl
vyzkouen peklad pod Delphi 1.0. Pro peklad je poteba vytvoit
soubor MODIF.INC. Peklad probhne sprvn v ppad, pokud bude soubor
przdn. Bude-li program bzet i v grafickm reimu je poteba do
souboru MODIF.INC vloit dek:
{$define graph}

10. Datov struktury

Zkladem je objekt obrzku definovan nsledujcm zpsobem:
     picture=object(AbstractPicture)
      filename:pathstr;
      x,y:integer;
      planes:byte;
      data:^lines;

      Function Valid:Boolean; virtual;
      procedure View; virtual;
      procedure Create(SizeX,SizeY:Word;pln:Byte);
      procedure Erase;
      Constructor Init;
      Destructor Done;
      end;

kde:x,y           znamen rozmry obrzku
    planes        poet bitovych rovin (lze pouzit pouze 1,2,4,8) pi
                  nahranm obrzku nedoporuuji mnit
    data          ukazatel na data uloen v pamti
    filename      jmno souboru obrzku na disku

A dle objekt vektorovho obrzku definovanho v nsledujc struktue:
     VectorPicture=object(AbstractPicture)
      xscale,yscale:integer;
      lines:Word;
      v:^AVectorObject;

      Procedure View; virtual;
      Procedure Erase;
      constructor Init;
      destructor Done;
      end;

kde   xscale,yscale rozmry vektorovho obrzku
      lines       poet objekt v poli v
      v           ukazatel pole ukazatel na jednotliv vektorov
                  objekty

Vektorov objekty jsou definovny nsledujcm zpsobem:
     VectorObject=record
      points:word;
        color:Byte;
      data:array[0..0] of point;
      end;

kde points        poet bod obsaench v objektu
    color   barva objektu
    data    pole jednotlivch bod patcch objektu


Struktura pro uloen dat histogramu:
     PHistogram=^THistogram;
     THistogram=Array[0..255]of Longint;

Dohoda:Jako souadnice Y je v obrzku uvaovna pozice dku.
      Jako souadnice X je v obrzku uvaovna pozice sloupce (pixel
      v dku).

11. Zkladn metody objektu picture

Function picture.Valid:Boolean; virtual;
      Vrac hodnotu True, pokud objekt obsahuje platn data. Jinak
Vrac False.

procedure picture.View; virtual;
      Zobraz objekt na obrazovku (viz procedura View).

procedure picture.Create(SizeX,SizeY:Word;pln:Byte);
      Vytvo nov przdn obrzek, kter m zadan rozmry a
poadovanou hloubku barev.

procedure picture.Erase;
      Zru vechna data objektu s vjimkou jmna obrzku. Tuto
proceduru je nutno volat v prbhu programu.

Constructor picture.Init;
      Inicializuje strukturu obrzku. Nutno vdy zavolat ped prvnm
pouitm objektu.

Destructor picture.Done;
      Nejprve vol picture.Erase a pak zru vechny ostatn informace
ve struktue obrzku.


12. Procedury pro pravu obrzk

12.1. Maskovn
  Procedure Mask(var Obr1,Obr2:Picture;n:Byte);
        Provede filtraci maskou z obrazku 1 do obrazku 2 s velikost
n. Pouv algoritmus dekomponovan masky, jeho rychlost neni zvisl
na rozmru masky.

12.2. Medin
  Procedure Median(var Obr1,Obr2:Picture;n:Byte);
        Provede filtraci medianem z obrazku 1 do obrazku 2 s velikosti
n. Pri spusteni je podle velikosti n vybran jeden ze dvou algoritmu.
Pro n<8 je pouzit rychly algoritmus s narocnosti n^3 a pro vyssi n je
pouzit jiny s k*n^2. Pro n>20 muze byt doba filtrace znacne dlouha.

12.3. Koprovn obrzku
Procedure MovePicture(var srP,destP:picture);
      Procedura provede pouze zkoprovn obsahu vchozho obrzku do
clovho. Obsahoval-li clov obrzek njak data, tato jsou
automaticky zruena. Pi koprovn nedojde k dn zmm dat ve
zdrojovm obrzku.

12.4. Gausova maska
Procedure Gauss(var Obr1,Obr2:Picture;n:Byte);
        Provede filtraci gausinem z obrazku 1 do obrazku 2 s velikost
n.

12.5. Oezn obrzku:
Procedure Crop(var Obr1,Obr2:Picture;x0,y0,x1,y1:word);
        Do obr2 ulo vyez z obr1 o souadnicch x0,y0,x1,y1.
Je-li parametr y1=0, pak jsou souradnice y0 a y1 vybrny automaticky
Je-li parametr x1=0, pak jsou souradnice x0 a x1 vybrny automaticky
 Automatick vbr oee rmeek obrazu, kter m stejnou barvu.

12.6. Detekce hran
Procedure Canny(var im_in,im_out:picture;GausN:integer;scale:real);
        Provede detekci hran v obrazku im_in a do im_out ulo vsledek
Cannyho hranoveho detektoru. Parametr GausN uruje poet iteranch
krok elementrn maskou 3x3 - tedy ve skutenosti mtko obrzku.
Parametr scale zpsob vynsoben vsledku konstantou, co je vhodn
v ppad pokud cannyho detektor v njakm obrzku dv jen velmi mal
poppad velk odezvy.
      Nulov nebo zporn hodnota parametru GausN mn innost
detektoru nsledujcm zpsobem:
Je provedena cel operace cannyho detektoru zptnm trasovnm hrany
od mtka obrazu definovanho parametrem GausN do mtka 1
(gausN,abs(scale))->...->(1,abs(scale)). Pro GausN=0 je potn
mtko=40.

12.7. Operace s jednm obrzkem
  Procedure Operation1(var obr1:picture;
      Operation:func1; ukParameters:Pointer);

        Provede zadanou transformaci jasu v jednom obrzku a vsledek
ulo do tho obrzku. Parametr Operation obsahuje poadovanou funkci.
T jsou pedvna jako parametr i uivatelema definovan data
odkazovan ukazatelem Param. Zatm jsou definovny nsledujc funkce:
 Procedure Invert(P1:Pointer;MaxX:Word;Dummy:pointer);            {R=-R}
 Procedure ReTabB(P1:Pointer;MaxX:Word;TabPtr:pointer);           {R:=Tab[R]}

      Je mono pidefinovat jakoukoliv novou funkci a pedat ji jako
parametr. Jedinou podmnkou je, aby  procedura byla typu far a aby se
jej hlavika shodovala s nsledujc definic:
     func1 = Procedure(P1:Pointer;MaxX:Word;ukParameters:Pointer);


12.8. Operace ze dvou obrzk
  Procedure Operation2(var obr1,obr2:picture;
      Operation:func2; Param:Pointer);

        Provede zadanou transformaci jasu ze dvou obrzk. Parametr
Operation obsahuje poadovanou funkci. T jsou pedvna jako parametr
i uivatelema definovan data odkazovan ukazatelem Param. Zatm jsou
definovny nsledujc funkce:
Procedure SubbS(P1,P2:Pointer;MaxX:Word;Dummy:pointer);           {R1:=R2-R1}
Procedure Add(P1,P2:Pointer;MaxX:Word;Dummy:pointer);             {R1:=R2+R1}

      Je mono pidefinovat jakoukoliv novou funkci a pedat ji jako
parametr. Jedinou podmnkou je, aby  procedura byla typu far a aby se
jej hlavika shodovala s nsledujc definic:
     func2 = Procedure(P1,P2:Pointer;MaxX:Word;ukParameters:pointer);


12.9. Zjitn histogramu
Procedure Histogram(var p:picture;var H:Phistogram);


13. Prce s binnmi obrzky

Definice strukturnho elementu:

Pro operace morfologie je poteba zadat jako parametr tvar strukturnho
elementu, se kterm bude provedena konvoluce. Jsou peddefinovny
nsledujc typy strukturnch element:
const ElLup=  4;   ElUp   =8;   ElRup  =16;
      ElLeft= 2;   ElCentr=1;   ElRight=32;
      ElLdown=256; ElDown =128; ElRdown=64;

      Z techto elementu lze slozit jakykoliv element do velikosti 3x3.
Jsou peddefinovany nsledujc sloen elementy:
 El8=ElLup+ElUp+ElRup+ElLeft+ElCentr+ElRight+ElLdown+ElDown+ElRdown;
 El4=ElUp+ElLeft+ElCentr+ElRight+ElDown;


13.1. Prahovn
  Procedure Thr(var Obr,ph:picture;h:integer);
      Provede prahovn Obrzku Obr s urenm prahem. Vsledn obrzek
je uloen do ph. Hodnota prahu 0 znamena automatickou volbu hodnoty
prahu podle histogramu {!!bude!!}.

13.2. Dilatace
  Procedure Dilatation(var Obr,ObrD:Picture;typ:Word);
      Dilatuje obrazek Obr do obrazku ObrD (Zatim pouze pro binarni
obrazky!). Promenna typ obsahuje tvar strukturniho elementu.

13.3. Eroze
  Procedure Erosion(var Obr,ObrD:Picture;typ:Word);
      Eroduje obrazek Obr do obrazku ObrD (Zatim pouze pro binarni
obrazky!). Promenna typ obsahuje tvar strukturniho elementu.

13.4. Binrn operace ze dvou obrzk
  Procedure BinarOperation2(var Obr1,Obr2:Picture;
Operation:BinarFunc2);
        Provede zadanou binrn funkci ze dvou binrnch obrazk.
Parametr Operation obsahuje poadovanou funkci. Zatm jsou definovny
nsledujc funkce:
 Procedure XorR(maxX:Word;R1,R2:Pointer);       {R1:=R1 xor R2}
 Procedure OrR(maxX:Word;R1,R2:Pointer);        {R1:=R1 or R2}
 Procedure AndR(maxX:Word;R1,R2:Pointer);       {R1:=R1 and R2}
      Lze pidefinovat jakkoliv nov funkce a pedat jako parametr.
Jedinou podmnkou je, aby  procedura byla typu far a aby se jej
hlavika shodovala s nsledujc definic:
     Binarfunc2 = Procedure(maxX:word;p1,p2:pointer);


14. Operace se vstupy/vstupy

14.1. Naten obrzku
  Procedure LoadPicture(var p:AbstractPicture;const s:PathStr);
      Nahraje obrzek zadanho jmena z disku. Typ obrzku pozn podle
typu prommnn pedan v parametru p. Jmno souboru je obsaeno v
promnn s. Je-li zadn przdn etzec, je pouito implicitn jmno
obrzku zan pomoc procedury AssignPicture v promnn p.filename.
      Jsou podporovny nsledujc formty bitmapovch obrzk: (BMP,
FTG, GIF, OKO, PCX, RAS). Pro vektorov obrzky jsou zatm dostupn dva
formty .TXT (textov) a .HPG (textov pro plotter).

14.2. Uloen obrzku
  Function SavePicture(var p:picture;const s:PathStr):Boolean;
      Ulo obrzek zadanho jmena na disk. Typ obrzku pozn podle
typu prommnn pedan v parametru p. Jmno souboru je obsaeno
v promnn s. Je-li zadn przdn etzec, je pouito implicitn jmno
obrzku zadan pomoc procedury AssignPicture v promnn
p.filename.Jmno je poteba zadat do promnn p.filename.
      Jsou podporovny nsledujc formty bitmapovch obrzk:(BMP,
PCX, RAS, OKO, FTG, TXT). Pro vektorov obrzky jsou zatm dostupn dva
formty .TXT (textov) a .HPG (textov pro plotter).

14.3. Nov formt FTG
      Je definovn v pdavn jednotce FTGR.PAS. Obsahuje novou metodu
komprese obrzk, kter je o nco innj ne dosud pouvan metody
komprese dat.
srovnn dlek:   

typ dat:    Obr A        ObrB        ObrC
      OKO   262656      442112      106940
      ZIP   227173      220369       10224
      ARJ   228451      220547       10380
      AIN   228496      221045       10559
      PCX   288650      377897       38624

      FTG   199697      177539        8922      - nov formt
            196440                              -   + LZW

Obrzek A je edotnov 256 rovov obrzek sejmut kamerou uml
scna.
Obrzek B je edotnov 256 rovov obrzek sejmut kamerou - pohled
do mstnosti .
Obrzek C je 1 rovov technick vkres (grafy).


15. Ostatn procedury s obrzky

15.1. Zobrazen
  Procedure view(var p:abstractPicture);
      Zobraz na obrazovce obrzek uloen v promnn p. Pro pouit
tto funkce je poteba v souboru MODIF.INC nastavit {$define graph}.

15.2. Peten pixelu
  Function pixel(var p:picture;x,y:integer):Word;
      Funkce vrac hodnotu pixelu v obrzku na pozici [x,y]. Nachz-li
se bod mimo obrzek, pak je vybrn nejbli bod v obrzku podle
vztahu: [max(0,min(SizeX,X)), max(0,min(SizeY,Y))].

15.3. Nastaven pixelu
  Procedure SetPixel(var p:picture; x,y:integer; n:Word);
      Procedura nastav pixelu na pozici [x,y] na hodnotu n. Nachz-li
se bod mimo obrzek, pak je vybrn nejbli bod v obrzku podle
vztahu: [max(0,min(SizeX,X)), max(0,min(SizeY,Y))].

15.4. Formtovan cel dky
  Procedure FormR(var p:picture; i:integer; Data:Pointer);
      Celou dku pevede do unifikovanho formtu word. Na pole slov
ukazuje ukazatel Data. Pamet o potrebne velikosti je potreba alokovat
pred zavolanim teto procedury. Pesahuje-li dka rozmry obrzku, pak
je vybrna nhradn dka podle vztahu: max(0,min(SizeY,Y)).

15.5. Nastaven cel dky:
  Procedure RfrmB(var p:picture;i: integer; NewData:Pointer);
      Zmn cel dek i v obrzku podle pole Wordu na ktere ukazuje
ukazatel NewData. Provd opanou funkci ne procedura FormR.
Pesahuje-li dka rozmry obrzku, pak je vybrna nhradn dka podle
vztahu: max(0,min(SizeY,Y)).

16. Peddefinovan programy

      K jednotce pictures je pidno i nkolik jednoduchch program,
kter demonstruj jej monosti pi zpracovn obrzk. Tyto programy
je mono pouvat i samostatn.
Spustiteln soubory jsou uloeny do 3 adres podle pouitho
prosted:
  DOS       pracuje pouze v relnm reimu
  DPMI      pracuje pouze mdu DPMI - monost prce s velkmi obrzky
  WIN       b v okn pod Windows

16.1. Convert
Parametry:vstupn_obrzek vstupn_obrzek [OutputPlanes] [/Gray]
                         [/NoScale]
          /?            vytiskne textovou npovdu
          /Gray         zru paletu a pevede barvy na tny edi
          /NoScale      zpsob, e pi konverzch bitovch rovin
                        nebudou data pepotvna, nbr oeznna.
          OutputPlanes        Poet bitovch rovin ve vstupnm obrzku.

      Provede konverzi vstupnho obrzku do vstupnho obrzku. Pi
tto konverzi povoluje zmnu potu bitovch rovin nebo zruen palety.
Poet bitovch rovin me bt pouze jedno z nsledujcch sel [1, 2,
4, 8, 16, 24, 32]. Pi zapnutm parametru noscale nedochz pi
konverzi k transformaci dat. Pokud njak hodnota pekro maximln
povolenou velikost pi uritm potu bitovch rovin, pak bude nastavena
prv na tuto maximln hodnotu (oezn).

16.2. Mask
Parametry:vstupn_obr [vstupn_obr] [n]
          /?                  vytiskne textovou npovdu
      Provd filtraci obrzku prmrovnm s maskou o zadan velikosti
(viz procedura Mask). Nen-li udno jmno vstupnho obrzku, pak je
pepsn pvodn vstupn soubor. slo n pedstavuje velikost tvercov
masky.

16.3. Median
Parametry:vstupn_obr [vstupn_obr] [n]
          /?                  vytiskne textovou npovdu
      Provd filtraci obrzku medinem s maskou o zadan velikosti
(viz procedura Median). Nen-li udno jmno vstupnho obrzku, pak je
pepsn pvodn vstupn soubor. slo n pedstavuje velikost tvercov
masky.

16.4. Morph
Parametry:vstupn_obr [vstupn_obr] [/D|E] [/Elxx]
         /?             vytiskne textovou npovdu
         /D nebo /E     volba dilatace nebo eroze
         /Elxx          Nastaven strukturnho elementu prpo konvoluci.
                        Zatm jsou podporovny El4 a El8 (osmiokol)

      Provd operace matemetick morfologie (tzn dilatace nebo eroze).
(viz procedury Dilatation a Erosion). Nen-li udno jmno vstupnho
obrzku, pak je pepsn pvodn vstupn soubor. Nejsou-li zadny dal
parametry je implicitn provedena operace dilatace na osmiokol.

16.5. View
Parametry:jmno_obrzku       zobraz obrzek
          /?                  vytiskne textovou npovdu
      Slou k prohlen obrzk na obrazovce monitoru. Zatm pouv
pouze reim 256 barev. Pomoc nho lze zobrazit vechny nsledujc
formty podporovan procedurou LoadPicture:
      BMP         1,4,8,24 bitovch rovin + paleta
      FTG         1,2,4,8,16,24,32 rovin (+voliteln paleta)
      GIF         1,2,4,8 rovin + paleta
      OKO         1,8 bitovch rovin (pouze ernoble)
      PCX         1*1,1*2,1*4,8*1 + paleta
      RAS         typy 0(1b),1(8b),2(8b),3(4b),4(4b)
      
      Pi prohlen lze interaktivn mnit rozlien obrazovky
funknmi klvesami F1 a F6. Stisk klvesy G doasn obnov/zru
barevnou paletu.

17. Registrace a pouvn programu

      Program je dodvn 'tak jak je' bez jakkoliv zruky. Autor
neru za jakkoliv kody zpsoben jeho innost.

      Program je zaazen do kategorie tzv CARDWARE. To znamen, pokud
se vm lb a chcete s nm dle pracovat, polete autorovi na ne
uvedenou adresu pohled s obrzkem vaeho msta. Mte-li Email, tak vm
bude poslna nejnovj verze programu. Nemte-li Email a mte-li zjem
o nejnovj verzi, polete autorovi v oblce disketu+pln zpten
potovn. (Pokud nebude obnos stait, tak Vae disketa propadne!)
      Chcete-li uvedenou sbrku procedur komern vyuvat, je poteba
se zaregistrovat. Poadavky na komern vyuit budu posuzovat
individuln a jsem ochoten za platu provst modifikaci zde uvedench
program. Tuto skutenost sdlte autorovi pomoc Emailu, nebo na
pohlednici.
      Autora zajmaj vechny pipomnky k innosti programu, chyby,
nvrhy, zlepen.

Autoi programu:
            Jaroslav Fojtk   ve ostatn

Dl sti:Pavel Pa - Cannyho detektor+Filtrace gausinem
            Pavel Krsek - Filtrace medinem
            
EMail:FOJTIK@control.felk.cvut.cz
Addresa:Jaroslav Fojtk
        Dvouramenn 13
        Praha 4 - Podol
        140 00    


18. Obsah


English version. . . . . . . . . . . . . . . . . . . . . . . . . . . . .   1

1. Compilation of unit . . . . . . . . . . . . . . . . . . . . . . . . .   1

2. Data structures . . . . . . . . . . . . . . . . . . . . . . . . . . .   1

3. Basic methods of object picture . . . . . . . . . . . . . . . . . . .   2

4. Procedures for processing pictures. . . . . . . . . . . . . . . . . .   2
      4.1. Mask filtration . . . . . . . . . . . . . . . . . . . . . . .   2
      4.2. Median filtration . . . . . . . . . . . . . . . . . . . . . .   2
      4.3. Copy of image . . . . . . . . . . . . . . . . . . . . . . . .   2
      4.4. Gaussian mask . . . . . . . . . . . . . . . . . . . . . . . .   2
      4.5. Crop of image:. . . . . . . . . . . . . . . . . . . . . . . .   3
      4.6. Edge detection. . . . . . . . . . . . . . . . . . . . . . . .   3
      4.7. Operations with one picture . . . . . . . . . . . . . . . . .   3
      4.8. Operations with two pictures. . . . . . . . . . . . . . . . .   3
      4.9. Computation of histogram. . . . . . . . . . . . . . . . . . .   3

5. Operations with binary pictures . . . . . . . . . . . . . . . . . . .   3
      5.1. Tresholding . . . . . . . . . . . . . . . . . . . . . . . . .   4
      5.2. Dilatation. . . . . . . . . . . . . . . . . . . . . . . . . .   4
      5.3. Erosion . . . . . . . . . . . . . . . . . . . . . . . . . . .   4
      5.4. Binary operations with two images . . . . . . . . . . . . . .   4

6. Input/Output Operations . . . . . . . . . . . . . . . . . . . . . . .   4
      6.1. Loading the image . . . . . . . . . . . . . . . . . . . . . .   4
      6.2. Saving image. . . . . . . . . . . . . . . . . . . . . . . . .   4
      6.3. New image format FTG. . . . . . . . . . . . . . . . . . . . .   5

7. Other procedures for manipulation with images . . . . . . . . . . . .   5
      7.1. Displaying. . . . . . . . . . . . . . . . . . . . . . . . . .   5
      7.2. Reading value of the pixel. . . . . . . . . . . . . . . . . .   5
      7.3. Set pixel value . . . . . . . . . . . . . . . . . . . . . . .   5
      7.4. Format of a row . . . . . . . . . . . . . . . . . . . . . . .   5
      7.5. Set of row. . . . . . . . . . . . . . . . . . . . . . . . . .   5

8. Ready programs. . . . . . . . . . . . . . . . . . . . . . . . . . . .   6
      8.1. Convert . . . . . . . . . . . . . . . . . . . . . . . . . . .   6

Czech version. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .   6

9. Peklad jednotky. . . . . . . . . . . . . . . . . . . . . . . . . . .   6

10. Datov struktury . . . . . . . . . . . . . . . . . . . . . . . . . .   6

11. Zkladn metody objektu picture. . . . . . . . . . . . . . . . . . .   7

12. Procedury pro pravu obrzk . . . . . . . . . . . . . . . . . . . .   8
      12.1. Maskovn. . . . . . . . . . . . . . . . . . . . . . . . . .   8
      12.2. Medin . . . . . . . . . . . . . . . . . . . . . . . . . . .   8
      12.3. Koprovn obrzku . . . . . . . . . . . . . . . . . . . . .   8
      12.4. Gausova maska. . . . . . . . . . . . . . . . . . . . . . . .   8
      12.5. Oezn obrzku: . . . . . . . . . . . . . . . . . . . . . .   8
      12.6. Detekce hran . . . . . . . . . . . . . . . . . . . . . . . .   8
      12.7. Operace s jednm obrzkem. . . . . . . . . . . . . . . . . .   8
      12.8. Operace ze dvou obrzk. . . . . . . . . . . . . . . . . . .   9
      12.9. Zjitn histogramu. . . . . . . . . . . . . . . . . . . . .   9

13. Prce s binnmi obrzky . . . . . . . . . . . . . . . . . . . . . .   9
      13.1. Prahovn. . . . . . . . . . . . . . . . . . . . . . . . . .   9
      13.2. Dilatace . . . . . . . . . . . . . . . . . . . . . . . . . .   9
      13.3. Eroze. . . . . . . . . . . . . . . . . . . . . . . . . . . .   9
      13.4. Binrn operace ze dvou obrzk. . . . . . . . . . . . . . .  10

14. Operace se vstupy/vstupy. . . . . . . . . . . . . . . . . . . . . .  10
      14.1. Naten obrzku. . . . . . . . . . . . . . . . . . . . . . .  10
      14.2. Uloen obrzku. . . . . . . . . . . . . . . . . . . . . . .  10
      14.3. Nov formt FTG. . . . . . . . . . . . . . . . . . . . . . .  10

15. Ostatn procedury s obrzky. . . . . . . . . . . . . . . . . . . . .  11
      15.1. Zobrazen. . . . . . . . . . . . . . . . . . . . . . . . . .  11
      15.2. Peten pixelu. . . . . . . . . . . . . . . . . . . . . . .  11
      15.3. Nastaven pixelu . . . . . . . . . . . . . . . . . . . . . .  11
      15.4. Formtovan cel dky . . . . . . . . . . . . . . . . . . .  11
      15.5. Nastaven cel dky:. . . . . . . . . . . . . . . . . . . .  11

16. Peddefinovan programy. . . . . . . . . . . . . . . . . . . . . . .  11
      16.1. Convert. . . . . . . . . . . . . . . . . . . . . . . . . . .  11
      16.2. Mask . . . . . . . . . . . . . . . . . . . . . . . . . . . .  11
      16.3. Median . . . . . . . . . . . . . . . . . . . . . . . . . . .  12
      16.4. Morph. . . . . . . . . . . . . . . . . . . . . . . . . . . .  12
      16.5. View . . . . . . . . . . . . . . . . . . . . . . . . . . . .  12

17. Registrace a pouvn programu. . . . . . . . . . . . . . . . . . .  12

18. Obsah. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  13
